package com.c201801020208.ybl.model.impl;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.c201801020208.ybl.R;
import com.tencent.imsdk.v2.V2TIMConversation;
import com.tencent.qcloud.tim.uikit.component.TitleBarLayout;
import com.tencent.qcloud.tim.uikit.modules.chat.ChatLayout;
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;
import com.tencent.qcloud.tim.uikit.modules.chat.base.OfflineMessageBean;

public class ChatActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);

        ChatLayout chatLayout = findViewById(R.id.chat_layout);// 从布局文件中获取聊天面板
        chatLayout.initDefault();// 单聊面板的默认 UI 和交互初始化
        // 传入 ChatInfo 的实例，这个实例必须包含必要的聊天信息，一般从调用方传入
        // 构造 mChatInfo 可参考 StartC2CChatActivity.java 的方法 startConversation
        ChatInfo chatInfo = (ChatInfo) getIntent().getSerializableExtra("CHAT_INFO");
        chatLayout.setChatInfo(chatInfo);

        TitleBarLayout titleBarLayout = chatLayout.findViewById(R.id.chat_title_bar);
        titleBarLayout.setRightIcon(R.drawable.shiping);
        //视频聊天
        titleBarLayout.setOnRightClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ChatActivity.this, RTCEntranceActivity.class);
                intent.putExtra("userid", chatInfo.getChatName());
                startActivity(intent);
            }
        });
    }
}
